define(function(){
  var hjx = function(){
    $.getJSON('data/home.json',function(responseText, responseState, responseObj){
  		// console.log(responseText);
  		var dataArr = responseText.data.act_info;
  		for(var i in dataArr){
  			// 轮播图数据
  			if(dataArr[i].type=="focus"){
  				var str1="",str11="";
  				var lbtArr = dataArr[i].act_rows;
  				for(var j in lbtArr){
  					str1 += '<img src=' + lbtArr[j].activity.img + ' alt="" />' ;
  					str11 += '<li></li>';
  				}
  				$("#middle").html(str1);
  				$("#lbtul").html(str11);
  			}
        // 导航部分数据
        if(dataArr[i].type=="icon"){
          var str2="";
          var navArr =  dataArr[i].act_rows;
          for(var j in navArr){
            str2 += '<div class="item">' +
        			         '<img src=' + navArr[j].activity.img + ' alt="" />' +
        			         '<p>' + navArr[j].activity.name + '</p>' +
        		        '</div>'
          }
          $("#nav").html(str2);
        }
        if(dataArr[i].type=="category"){
          var str3="";
          var categoryArr = dataArr[i].act_rows;
          for(var j in categoryArr){
            var goodsArr = categoryArr[j].category_detail.goods;
            var str31="";
            for(var k in goodsArr){
              var str32="",str33="";
              if(goodsArr[k].d_price==undefined){
                str32 +='<span class="oldprice"></span>';
              }else{
                str32 +='<span class="oldprice">￥' + goodsArr[k].d_price  + '</span>';
              }
              if(goodsArr[k].org_source_value==1){
                str33 += '<p class="p">精选</p>';
              }else if(goodsArr[k].org_source_value==2){
                str33 = '<p class="pp"></p>';
              }
            str31 += '<div class="div">'+
                        '<img src=' + goodsArr[k].img + ' alt="">' +
                        '<p class="title">' + goodsArr[k].name + '</p>'+
                        str33 +
                        '<div class="youhui">' + goodsArr[k].pm_desc  + '</div>'+
                        '<span class="mass">' + goodsArr[k].specifics  + '</span>'+
                        '<span class="price">￥'+ goodsArr[k].price + '</span>'+
                        str32 +
                        '<div class="add">+</div>'+
                      '</div>'
            }
            str3 += '<div class="style2">'+
                      '<div class="item1">'+
                        '<div class="title">'+
                          '<div class=""></div>'+
                          '<p>' + categoryArr[j].category_detail.name + '</p>' +
                        '</div>'+
                        '<span>更多 &gt;</span>'+
                      '</div>'+
                      '<div class="item2">'+
                        '<img src=' + categoryArr[j].activity.img + ' alt="">' +
                      '</div>'+
                      '<div class="item3">'+
                          str31 +
                      '</div>'+
                    '</div>'
          }

          $("#category").html(str3);
        }
        if(dataArr[i].type=="brand"){
          var str4="";
          var brandArr = dataArr[i].act_rows;
          for(var j in brandArr){
            str4 += '<img src=' + brandArr[j].activity.img  + ' alt="" />'
          }
          $("#banner").html(str4);
        }
        if(dataArr[i].type=="business"){
          var str5="";
          var businessArr = dataArr[i].act_rows;
          for(var j in businessArr){
            if(businessArr[j].type=="chead"){
              str5 += '<ul class="ul1">'+
                  			'<li><img src=' + businessArr[j].act_rows[0].chead_detail.img + ' alt="" /></li>'+
                  		'</ul>'
            }
            if(businessArr[j].type=='cactivity'){
              var str51 = "";
              var cactivityArr = businessArr[j].act_rows;
              for(var k in cactivityArr){
                str51 += '<li><img src=' + cactivityArr[k].cactivity_detail.img + ' alt="" /></li>'
              }
              str5 += '<ul class="ul2">'+
                  			'<span></span>'+
                  			str51+
                  			'<span></span>'+
                  		'</ul>'
            }
            if(businessArr[j].type=='cicons'){
              var str52 = "";
              var ciconsArr = businessArr[j].act_rows;
              for(var k in ciconsArr){
                str52 += '<li>'+
                  				'<img src=' + ciconsArr[k].cicons_detail.img + ' alt="" />'+
                  				'<p>' + ciconsArr[k].cicons_detail.name + '</p>'+
                  			'</li>'
              }
              str5 += '<ul class="ul3">' + str52 + '</ul>'
            }
            if(businessArr[j].type=='cscene'){
              var str53="";
              var csceneArr = businessArr[j].act_rows;
              for(var k in csceneArr){
                str53 += '<li><img src=' + csceneArr[k].activity.img + ' alt="" /></li>'
              }
              str5 += '<ul class="ul4">' + str53 + '</ul>'
            }
          }
          $('.style1').html(str5);
        }
  		}

      // 点击加号效果
  		var $add = $(".add");
      var $show = $(".show");
      for(var i=0;i<$add.length;i++){
        (function(num){
          $($add[num]).click(function(){
            $show.css("display","block");
            var nums = parseInt($show.html());
            $show.html(nums + 1);
          })
        })(i);
      }


  	});
  }
  return {
    hjx:hjx
  }
})
